package com.lichao.FinkDataProcess.compare;





import com.alibaba.fastjson.JSONObject;

import java.lang.reflect.Field;

/**
 * @author: li chao
 * @Desc:
 * @create: 2024-11-15 21:14
 **/
public class InCompareNode extends CompareNode{

    public InCompareNode(String fieldName, String operateType, Object value) {
        super(fieldName, operateType, value);
    }

    @Override
    public boolean compare(JSONObject json) throws Exception {
        Field field = JSONObject.class.getDeclaredField(this.getFieldName());
        field.setAccessible(true);
        this.setField(field);

        if ("in".equals(this.getOperateType())) {
            return this.getField().get(json).toString().equals(this.getValue());
        }
        return false;
    }
}
